---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\fsu2010\formateur\ajps\submission2\replication\analysis\changelp.log
  log type:  text
 opened on:  15 Nov 2010, 10:31:59

. #delimit ;
delimiter now ;
. set mem 30m;

Current memory allocation

                    current                                 memory usage
    settable          value     description                 (1M = 1024k)
    --------------------------------------------------------------------
    set maxvar         5000     max. variables allowed           1.947M
    set memory           30M    max. data space                 30.000M
    set matsize         400     max. RHS vars in models          1.254M
                                                            -----------
                                                                33.201M

. /*clear matrix;*/
> /*clear mata; */
> 
> set more off;

. *     ***************************************************************** *;
. *     ***************************************************************** *;
. *       File-Name:  stata_mxl_predictprob.do                            *;
. *       Date:       November 9, 2010                                    *;
. *       Author:     GG/MG                                               *;
. *       Purpose:    Produce Tables 1 and 2 in AJPS paper                *;
. *       Input File:     europe.dta                                      *;
. *       Output File:    stata_mxl_predictprob.log                       *;
. *       Data Output:    none                                            *;
. *       Previous file:  europe.dta                                      *;
. *       Machine:        Matt's desktop                                  *;
. *     ****************************************************************  *;
. *     ****************************************************************  *;
. use "europe.dta", clear;

. *     ****************************************************************  *;
. *       Model 6: Western Europe                                         *;
. *     ****************************************************************  *;
. mixlogit choice largestparty_east party_seatshare_east medianparty1_east presidentparty_east previousPM_east previousPM_conflict_east previousPM_gain1_east previous_cabinet_gain1_east,  
>     rand (largestparty party_seatshare medianparty1 presidentparty previousPM president_investiture president_direct previousPM_conflict previousPM_gain1 previous_cabinet_gain1) 
>     ln(0) nrep(125) group(cabinetcode);

Iteration 0:   log likelihood = -255.29786  (not concave)
Iteration 1:   log likelihood = -245.38797  (not concave)
Iteration 2:   log likelihood =  -228.8695  
Iteration 3:   log likelihood = -221.24204  (not concave)
Iteration 4:   log likelihood = -221.16184  (not concave)
Iteration 5:   log likelihood = -220.39987  
Iteration 6:   log likelihood = -219.61402  
Iteration 7:   log likelihood = -219.46931  
Iteration 8:   log likelihood = -219.42816  (not concave)
Iteration 9:   log likelihood = -219.41127  (not concave)
Iteration 10:  log likelihood = -219.40733  (not concave)
Iteration 11:  log likelihood = -219.38013  
Iteration 12:  log likelihood = -219.35918  
Iteration 13:  log likelihood = -219.35268  
Iteration 14:  log likelihood = -219.35266  

Mixed logit model                                 Number of obs   =       2039
                                                  LR chi2(10)     =      19.54
Log likelihood = -219.35266                       Prob > chi2     =     0.0339

------------------------------------------------------------------------------
      choice |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
Mean         |
largestp~ast |  -1.253544   2.017873    -0.62   0.534    -5.208503    2.701414
party_se~ast |   .2877481   .1444587     1.99   0.046     .0046143    .5708819
medianpa~ast |  -3.117227   1.721757    -1.81   0.070    -6.491809    .2573546
presi~y_east |  -.4970681   1.853252    -0.27   0.789    -4.129376     3.13524
previ~M_east |   -2.19965   2.606521    -0.84   0.399    -7.308337    2.909037
previ~t_east |   1.126725   3.208478     0.35   0.725    -5.161776    7.415226
previousPM.. |  -.0930831   .4810077    -0.19   0.847    -1.035841    .8496746
previous_c.. |   .0517841   .1988117     0.26   0.795    -.3378797    .4414479
largestparty |   2.109018   1.104417     1.91   0.056    -.0555996    4.273637
party_seat~e |   .1351541   .0258657     5.23   0.000     .0844583    .1858498
medianparty1 |   1.392319   .3828235     3.64   0.000     .6419985    2.142639
presidentp~y |   5.250695   2.428888     2.16   0.031     .4901621    10.01123
  previousPM |   2.841572   1.038968     2.73   0.006     .8052325    4.877912
president_~e |  -3.060496   2.130412    -1.44   0.151    -7.236027    1.115035
president~ct |  -3.915977     2.1442    -1.83   0.068    -8.118531    .2865774
previousP~ct |  -2.618633   1.261868    -2.08   0.038    -5.091848   -.1454174
previousPM~1 |   .4958572   .2007184     2.47   0.013     .1024564     .889258
previous_c~1 |   .0367127   .0403208     0.91   0.363    -.0423147    .1157401
-------------+----------------------------------------------------------------
SD           |
largestparty |   -4.72622   1.779758    -2.66   0.008    -8.214482   -1.237958
party_seat~e |  -.0074871   .0352742    -0.21   0.832    -.0766233    .0616491
medianparty1 |    .137813   .9798871     0.14   0.888     -1.78273    2.058356
presidentp~y |  -.2669029   1.275177    -0.21   0.834    -2.766204    2.232398
  previousPM |   -1.90488   1.048407    -1.82   0.069     -3.95972    .1499602
president_~e |  -.4246113   1.592647    -0.27   0.790    -3.546143     2.69692
president~ct |   .5917079    1.45034     0.41   0.683    -2.250906    3.434321
previousP~ct |  -.1339578   2.773063    -0.05   0.961    -5.569061    5.301145
previousPM~1 |   .1120099   .2052588     0.55   0.585      -.29029    .5143099
previous_c~1 |   .1484155   .0862284     1.72   0.085    -.0205892    .3174201
------------------------------------------------------------------------------
The sign of the estimated standard deviations is irrelevant: interpret them as
being positive

.     *     ****************************************************************  *;
. *       Now produce Figure 1                                            *;
. *     ****************************************************************  *;
. matrix coeffs = e(b);

. matrix covmat = e(V);

. keep if cabinetcode==1222;
(2400 observations deleted)

. set obs 10000;
obs was 12, now 10000

. generate pvda = 0;

. replace pvda = 1 if partyID==7;
(1 real change made)

. generate cda = 0;

. replace cda = 1 if partyID==13;
(1 real change made)

. generate vvd = 0;

. replace vvd = 1 if partyID==22;
(1 real change made)

. generate d66 = 0;

. replace d66 = 1 if partyID==10;
(1 real change made)

. generate ppvda1 = .;
(10000 missing values generated)

. generate pcda1 = .;
(10000 missing values generated)

. generate pvvd1 = .;
(10000 missing values generated)

. generate pd661 = .;
(10000 missing values generated)

. generate ppvda2 = .;
(10000 missing values generated)

. generate pcda2 = .;
(10000 missing values generated)

. generate pvvd2 = .;
(10000 missing values generated)

. generate pd662 = .;
(10000 missing values generated)

. generate ppvda3 = .;
(10000 missing values generated)

. generate pcda3 = .;
(10000 missing values generated)

. generate pvvd3 = .;
(10000 missing values generated)

. generate pd663 = .;
(10000 missing values generated)

. generate ppvda4 = .;
(10000 missing values generated)

. generate pcda4 = .;
(10000 missing values generated)

. generate pvvd4 = .;
(10000 missing values generated)

. generate pd664 = .;
(10000 missing values generated)

. drawnorm b1-b28, means(coeffs) cov(covmat) double;

.  nois _dots 0, title(largest party sim) reps(10000);
largest party sim (10000)
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 

. forvalues j = 1/10000 {;
  2.   mkmat b1-b28 if _n==`j', matrix(bdraw);
  3.   mixlpred2 pprobs;
  4.    qui generate pt1 = pprobs * pvda;
  5.   qui generate ct1 = pprobs * cda;
  6.   qui generate vt1 = pprobs * vvd;
  7.   qui generate dt1 = pprobs * d66;
  8.   qui replace largestparty = 0 if pvda==1;
  9.   qui replace party_seatshare = 22.66667 if pvda==1;
 10.   qui replace largestparty = 1 if cda==1;
 11.   qui replace party_seatshare = 24.66667 if cda==1;
 12. mixlpred2 pprobs2;
 13.   qui generate pt2 = pprobs2 * pvda;
 14.   qui generate ct2 = pprobs2 * cda;
 15.   qui generate vt2 = pprobs2 * vvd;
 16.   qui generate dt2 = pprobs2 * d66;
 17.   qui replace largestparty = 0 if cda==1;
 18.   qui replace party_seatshare = 22.66667 if cda==1;
 19.   qui replace party_seatshare = 20.66667 if pvda==1;
 20.   qui replace largestparty = 1 if vvd==1;
 21.   qui replace party_seatshare = 24.66667 if vvd==1;
 22. mixlpred2 pprobs3;
 23.   qui generate pt3 = pprobs3 * pvda;
 24.   qui generate ct3 = pprobs3 * cda;
 25.   qui generate vt3 = pprobs3 * vvd;
 26.   qui generate dt3 = pprobs3 * d66;
 27.   qui replace largestparty = 0 if vvd==1;
 28.   qui replace party_seatshare = 20.66667 if vvd==1;
 29.   qui replace party_seatshare = 16 if pvda==1;
 30.   qui replace largestparty = 1 if d66==1;
 31.   qui replace party_seatshare = 24.66667 if d66==1;
 32. mixlpred2 pprobs4;
 33.   qui generate pt4 = pprobs4 * pvda;
 34.   qui generate ct4 = pprobs4 * cda;
 35.   qui generate vt4 = pprobs4 * vvd;
 36.   qui generate dt4 = pprobs4 * d66;
 37.   qui replace largestparty = 1 if pvda==1;
 38.   qui replace party_seatshare = 24.66667 if pvda==1;
 39.   qui replace largestparty = 0 if d66==1;
 40.   qui replace party_seatshare = 16 if d66==1;
 41.   egen pt1s = sum(pt1);
 42.   egen ct1s = sum(ct1);
 43.   egen vt1s = sum(vt1);
 44.   egen dt1s = sum(dt1);
 45.   egen pt2s = sum(pt2);
 46.   egen ct2s = sum(ct2);
 47.   egen vt2s = sum(vt2);
 48.   egen dt2s = sum(dt2);
 49.   egen pt3s = sum(pt3);
 50.   egen ct3s = sum(ct3);
 51.   egen vt3s = sum(vt3);
 52.   egen dt3s = sum(dt3);
 53.   egen pt4s = sum(pt4);
 54.   egen ct4s = sum(ct4);
 55.   egen vt4s = sum(vt4);
 56.   egen dt4s = sum(dt4);
 57.   qui replace ppvda1 = pt1s if _n==`j';
 58.   qui replace pcda1 = ct1s if _n==`j';
 59.   qui replace pvvd1 = vt1s if _n==`j';
 60.   qui replace pd661 = dt1s if _n==`j';
 61.   qui replace ppvda2 = pt2s if _n==`j';
 62.   qui replace pcda2 = ct2s if _n==`j';
 63.   qui replace pvvd2 = vt2s if _n==`j';
 64.   qui replace pd662 = dt2s if _n==`j';
 65.   qui replace ppvda3 = pt3s if _n==`j';
 66.   qui replace pcda3 = ct3s if _n==`j';
 67.   qui replace pvvd3 = vt3s if _n==`j';
 68.   qui replace pd663 = dt3s if _n==`j';
 69.   qui replace ppvda4 = pt4s if _n==`j';
 70.   qui replace pcda4 = ct4s if _n==`j';
 71.   qui replace pvvd4 = vt4s if _n==`j';
 72.   qui replace pd664 = dt4s if _n==`j';
 73. drop pt1 ct1 vt1 dt1 pt2 ct2 vt2 dt2 pt3 ct3 vt3 dt3 pt4 ct4 vt4 dt4 
> pt1s ct1s vt1s dt1s pt2s ct2s vt2s dt2s pt3s ct3s vt3s dt3s pt4s ct4s vt4s dt4s 
> pprobs pprobs2 pprobs3 pprobs4;
 74.  nois _dots `j' 0;
 75.   };
..................................................    50
..................................................   100
..................................................   150
..................................................   200
..................................................   250
..................................................   300
..................................................   350
..................................................   400
..................................................   450
..................................................   500
..................................................   550
..................................................   600
..................................................   650
..................................................   700
..................................................   750
..................................................   800
..................................................   850
..................................................   900
..................................................   950
..................................................  1000
..................................................  1050
..................................................  1100
..................................................  1150
..................................................  1200
..................................................  1250
..................................................  1300
..................................................  1350
..................................................  1400
..................................................  1450
..................................................  1500
..................................................  1550
..................................................  1600
..................................................  1650
..................................................  1700
..................................................  1750
..................................................  1800
..................................................  1850
..................................................  1900
..................................................  1950
..................................................  2000
..................................................  2050
..................................................  2100
..................................................  2150
..................................................  2200
..................................................  2250
..................................................  2300
..................................................  2350
..................................................  2400
..................................................  2450
..................................................  2500
..................................................  2550
..................................................  2600
..................................................  2650
..................................................  2700
..................................................  2750
..................................................  2800
..................................................  2850
..................................................  2900
..................................................  2950
..................................................  3000
..................................................  3050
..................................................  3100
..................................................  3150
..................................................  3200
..................................................  3250
..................................................  3300
..................................................  3350
..................................................  3400
..................................................  3450
..................................................  3500
..................................................  3550
..................................................  3600
..................................................  3650
..................................................  3700
..................................................  3750
..................................................  3800
..................................................  3850
..................................................  3900
..................................................  3950
..................................................  4000
..................................................  4050
..................................................  4100
..................................................  4150
..................................................  4200
..................................................  4250
..................................................  4300
..................................................  4350
..................................................  4400
..................................................  4450
..................................................  4500
..................................................  4550
..................................................  4600
..................................................  4650
..................................................  4700
..................................................  4750
..................................................  4800
..................................................  4850
..................................................  4900
..................................................  4950
..................................................  5000
..................................................  5050
..................................................  5100
..................................................  5150
..................................................  5200
..................................................  5250
..................................................  5300
..................................................  5350
..................................................  5400
..................................................  5450
..................................................  5500
..................................................  5550
..................................................  5600
..................................................  5650
..................................................  5700
..................................................  5750
..................................................  5800
..................................................  5850
..................................................  5900
..................................................  5950
..................................................  6000
..................................................  6050
..................................................  6100
..................................................  6150
..................................................  6200
..................................................  6250
..................................................  6300
..................................................  6350
..................................................  6400
..................................................  6450
..................................................  6500
..................................................  6550
..................................................  6600
..................................................  6650
..................................................  6700
..................................................  6750
..................................................  6800
..................................................  6850
..................................................  6900
..................................................  6950
..................................................  7000
..................................................  7050
..................................................  7100
..................................................  7150
..................................................  7200
..................................................  7250
..................................................  7300
..................................................  7350
..................................................  7400
..................................................  7450
..................................................  7500
..................................................  7550
..................................................  7600
..................................................  7650
..................................................  7700
..................................................  7750
..................................................  7800
..................................................  7850
..................................................  7900
..................................................  7950
..................................................  8000
..................................................  8050
..................................................  8100
..................................................  8150
..................................................  8200
..................................................  8250
..................................................  8300
..................................................  8350
..................................................  8400
..................................................  8450
..................................................  8500
..................................................  8550
..................................................  8600
..................................................  8650
..................................................  8700
..................................................  8750
..................................................  8800
..................................................  8850
..................................................  8900
..................................................  8950
..................................................  9000
..................................................  9050
..................................................  9100
..................................................  9150
..................................................  9200
..................................................  9250
..................................................  9300
..................................................  9350
..................................................  9400
..................................................  9450
..................................................  9500
..................................................  9550
..................................................  9600
..................................................  9650
..................................................  9700
..................................................  9750
..................................................  9800
..................................................  9850
..................................................  9900
..................................................  9950
.................................................. 10000

. generate pvdad2 = ppvda2 - ppvda1;

. generate pvdad3 = ppvda3 - ppvda1;

. generate pvdad4 = ppvda4 - ppvda1;

. generate cdad2 = pcda2 - pcda1;

. generate cdad3 = pcda3 - pcda1;

. generate cdad4 = pcda4 - pcda1;

. generate vvdd2 = pvvd2 - pvvd1;

. generate vvdd3 = pvvd3 - pvvd1;

. generate vvdd4 = pvvd4 - pvvd1;

. generate d66d2 = pd662 - pd661;

. generate d66d3 = pd663 - pd661;

. generate d66d4 = pd664 - pd661;

. summarize 
> ppvda1 pcda1 pvvd1 pd661
> ppvda2 pcda2 pvvd2 pd662
> ppvda3 pcda3 pvvd3 pd663
> ppvda4 pcda4 pvvd4 pd664
> pvdad2 cdad2 vvdd2 d66d2
> pvdad3 cdad3 vvdd3 d66d3
> pvdad4 cdad4 vvdd4 d66d4;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
      ppvda1 |     10000    .5773833    .1025367   .0105241    .773866
       pcda1 |     10000     .143042    .1034168   .0003944   .8688393
       pvvd1 |     10000    .1229365    .0325492   .0276582   .3235208
       pd661 |     10000    .0639232    .0148604   .0139242   .1705652
      ppvda2 |     10000    .2052213    .0510039    .044188   .4041705
-------------+--------------------------------------------------------
       pcda2 |     10000    .4389874    .1129329   .0442368   .8448154
       pvvd2 |     10000    .1539688     .034849   .0399159   .2773999
       pd662 |     10000    .0810762    .0170804    .023936   .1414753
      ppvda3 |     10000    .1229365    .0325492   .0276582   .3235208
       pcda3 |     10000     .143042    .1034168   .0003944   .8688393
-------------+--------------------------------------------------------
       pvvd3 |     10000    .5773833    .1025367   .0105241    .773866
       pd663 |     10000    .0639232    .0148604   .0139242   .1705652
      ppvda4 |     10000    .0639232    .0148604   .0139242   .1705652
       pcda4 |     10000     .143042    .1034168   .0003944   .8688393
       pvvd4 |     10000    .1229365    .0325492   .0276582   .3235208
-------------+--------------------------------------------------------
       pd664 |     10000    .5773833    .1025367   .0105241    .773866
      pvdad2 |     10000   -.3721619    .1033021  -.6232564   .2108341
       cdad2 |     10000    .2959454    .1014109  -.2903856    .573568
       vvdd2 |     10000    .0310323    .0195962  -.0645593   .1313421
       d66d2 |     10000     .017153    .0104785  -.0330051   .0741882
-------------+--------------------------------------------------------
      pvdad3 |     10000   -.4544468    .1083123  -.6978838   .1928599
       cdad3 |     10000    3.73e-13    3.73e-11          0   3.73e-09
       vvdd3 |     10000    .4544468    .1083123  -.1928599   .6978838
       d66d3 |     10000   -2.61e-12    2.61e-10  -2.61e-08          0
      pvdad4 |     10000   -.5134601    .1064788  -.7298976   .0637219
-------------+--------------------------------------------------------
       cdad4 |     10000    3.73e-13    3.73e-11          0   3.73e-09
       vvdd4 |     10000    1.49e-12    1.49e-10          0   1.49e-08
       d66d4 |     10000    .5134601    .1064788  -.0637219   .7298976

. 
end of do-file

. log close
      name:  <unnamed>
       log:  C:\fsu2010\formateur\ajps\submission2\replication\analysis\changelp.log
  log type:  text
 closed on:  15 Nov 2010, 16:18:51
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
